<!-- 商户入驻 -->
<template>
	<s-layout :bgStyle="{ color: '#FFF' }" title="商户入驻" v-if="state.dianpuEnabled == false">
		<commission-apply-dianpu />
	</s-layout>
	<s-layout navbar="inner" class="index-wrap" title="代理中心" :bgStyle="bgStyle" :onShareAppMessage="shareInfo" v-if="state.dianpuEnabled == true">
		<!-- 分销商信息 -->
		<commission-info />
		<!-- 账户信息 -->
		<account-info  />
		<!-- 菜单栏 -->
		<commission-menu  />
		<!-- 分销记录 -->
		<!-- <commission-log  /> -->
		<!-- 权限弹窗 -->
		<commission-auth />
	</s-layout>
</template>

<script setup>
	import {
		onBeforeMount,
		reactive,
		computed
	} from 'vue';
	import {
		onLoad,
		onShow
	} from '@dcloudio/uni-app';
	import sheep from '@/sheep';
	import {
		isEmpty
	} from 'lodash-es';
	import commissionApplyDianpu from './components/commission-apply-dianpu.vue';
	import commissionInfo from './components/commission-info.vue';
	import accountInfo from './components/account-info.vue';
	import commissionLog from './components/commission-log.vue';
	import commissionMenu from './components/commission-menu.vue';
	import commissionAuth from './components/commission-auth.vue';
	
	import BrokerageApi from '@/sheep/api/trade/brokerage';
	
	import {
		SharePageEnum,
		getBrokerageTitleEnum,
		BrokerageTypeEnum
	} from '@/sheep/util/const';

	const state = reactive({
		list: [], // 地址列表
		loading: true,
		openType: '', // 页面打开类型
		dianpuEnabled: false, // 审核通过
	});
	
	/** 分销邀请 */
	const shareInfo = computed(() => {
		return sheep.$platform.share.getShareInfo({
			params: {
				page: SharePageEnum.HOME.value, // 用户通邀请进入到首页
			},
		}, {
			type: 'user',
		});
	});
	
	const bgStyle = {
		color: '#F7D598',
	};
	
	// 获得代理申请数据
	const getBrokerageInfo = () => {
		BrokerageApi.getBrokerageUserApplyInfo({
			applyType: BrokerageTypeEnum.DZ.type,
		}).then((res) => {
			if (res.code === 0) {
				state.dianpuEnabled = res.data.isEnabled;
			}
		})
	};
	
	onLoad(async (options) => {
		// 获取代理申请审核信息
		getBrokerageInfo();
	});
</script>

<style lang="scss" scoped>
	.footer-box {
		.add-btn {
			flex: 1;
			background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
			border-radius: 80rpx;
			font-size: 30rpx;
			font-weight: 500;
			line-height: 80rpx;
			color: $white;
			position: relative;
			z-index: 1;
		}

		.sync-wxaddress {
			flex: 1;
			line-height: 80rpx;
			background: $white;
			border-radius: 80rpx;
			font-size: 30rpx;
			font-weight: 500;
			color: $dark-6;
			margin-right: 18rpx;
		}
	}
</style>